Pivot Sampling in Dual-Pivot Quicksort
نویسندگان
چکیده
The new dual-pivot Quicksort by Vladimir Yaroslavskiy — used in Oracle’s Java runtime library since version 7 — features intriguing asymmetries in its behavior. They were shown to cause a basic variant of this algorithm to use less comparisons than classic single-pivot Quicksort implementations. In this paper, we extend the analysis to the case where the two pivots are chosen as fixed order statistics of a random sample and give the precise leading term of the average number of comparisons, swaps and executed Java Bytecode instructions. It turns out that — unlike for classic Quicksort, where it is optimal to choose the pivot as median of the sample — the asymmetries in Yaroslavskiy’s algorithm render pivots with a systematic skew more efficient than the symmetric choice. Moreover, the optimal skew heavily depends on the employed cost measure; most strikingly, abstract costs like the number of swaps and comparisons yield a very different result than counting Java Bytecode instructions, which can be assumed most closely related to actual running time.
منابع مشابه
Pivot Sampling in Java 7's Dual-Pivot Quicksort
The new dual-pivot Quicksort by Vladimir Yaroslavskiy — used in Oracle’s Java runtime library since version 7 — features intriguing asymmetries in its behavior. They were shown to cause a basic variant of this algorithm to use less comparisons than classic single-pivot Quicksort implementations. In this paper, we extend the analysis to the case where the two pivots are chosen as fixed order sta...
متن کاملWhy Is Dual-Pivot Quicksort Fast?
I discuss the new dual-pivot Quicksort that is nowadays used to sort arrays of primitive types in Java. I sketch theoretical analyses of this algorithm that offer a possible, and in my opinion plausible, explanation why (a) dual-pivot Quicksort is faster than the previously used (classic) Quicksort and (b) why this improvement was not already found much earlier.
متن کاملDual pivot Quicksort
In this paper, we analyse the dual pivot Quicksort, a variant of the standard Quicksort algorithm, in which two pivots are used for the partitioning of the array. We are solving recurrences of the expected number of key comparisons and exchanges performed by the algorithm, obtaining the exact and asymptotic total average values contributing to its time complexity. Further, we compute the averag...
متن کاملProbabilistic Analysis of the Dual-Pivot Quicksort "Count"
Recently, Aumüller and Dietzfelbinger proposed a version of a dual-pivot quicksort, called “Count”, which is optimal among dual-pivot versions with respect to the average number of key comparisons required. In this note we provide further probabilistic analysis of “Count”. We derive an exact formula for the average number of swaps needed by “Count” as well as an asymptotic formula for the varia...
متن کاملIntroduction to Randomized Algorithms: QuickSort and QuickSelect
QuickSort Hoare [1962] (A) Pick a pivot element from array (B) Split array into 3 subarrays: those smaller than pivot, those larger than pivot, and the pivot itself. (C) Recursively sort the subarrays, and concatenate them. Randomized QuickSort (A) Pick a pivot element uniformly at random from the array (B) Split array into 3 subarrays: those smaller than pivot, those larger than pivot, and the...
متن کامل